tmpFile="${CURDIR}/download.tgz"
installDir="{{installDir}}"
binUrl="https://github.com/containerd/nerdctl/releases/download/v0.10.0/nerdctl-full-0.10.0-linux-amd64.tar.gz"

install: download.tgz 
	if [ -L /usr/local/bin/docker ]; then rm -f /usr/local/bin/docker;fi
	if [ -L /usr/local/bin/dtr ]; then rm -f /usr/local/bin/dtr; fi
	tar -zxvf ${tmpFile} -C ${installDir}/ > ${CURDIR}/rollback.list &&  \
	ln -s /usr/local/bin/nerdctl /usr/local/bin/docker && \
	ln -s /usr/local/bin/nerdctl /usr/local/bin/dtr && \
	/usr/local/bin/containerd config default > /etc/containerd/config.toml	

download.tgz:
	https_proxy={{proxyUrl}} wget -O ${tmpFile} ${binUrl}

uninstall:
	cat ${CURDIR}/rollback.list | while read line; do \
	  if [ -f "/usr/local/$$line" ]; then \
	    echo "delete file: /usr/local/$$line"; \
		rm -f /usr/local/$$line; \
	  fi; \
	done
